package org.ros.android.android_tutorial_image_transport;

import android.content.Context;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
import android.view.Gravity;

/**
 * Created by corvin on 17-8-7.
 */

public class Utility {
    private static Toast toast;

    public static void showToast(Context context,String content)
    {
        if (toast == null)
        {
            toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
            toast.setGravity(Gravity.CENTER, 0, 0);
            LinearLayout toastView = (LinearLayout) toast.getView();
            ImageView imageCodeProject = new ImageView(context);
            imageCodeProject.setImageResource(R.drawable.warn);
            toastView.addView(imageCodeProject, 0);
        }
        else
        {
            toast.setText(content);
        }
        toast.show();
    }
}
